//
// Created by blackplume on 17-10-19.
//

#ifndef MYSHELL_BUILDIN_COMMAND_H
#define MYSHELL_BUILDIN_COMMAND_H


#include <zconf.h>

#define IN_COMMAND_NUM 4

#define DEBUG

#define NO_FORK 1
struct out_Command{
    char * name;
    char * path;
};


struct read_info{
    bool  IsBuildin;
    bool  IsBuildin2;
    int   index;
    int   index2;
    bool  IsPath;
    bool  IsPath2;
    char* Path;
    char* Path2;
    bool  IsPipe;
    int  IsRedirect;
    char* Redirect;
    int  IsRedirect2;
    char* Redirect2;
};

struct in_Command{
    char * name;
    int (*func)( char**parameters,char *&out);
    int fmode;
    in_Command( char * name,int (*fun)( char**parameters,char *&out));
    in_Command( char * name,int (*fun)( char**parameters,char *&out),int mode);
};



static  in_Command** in_command;

void Init();


int  GetIndex(const char * name);

void run(int index, char** parameters, char*&out);

int Redirection(read_info * info,char *path);
int isFork(int i);
int repipe();

int DoCommand(read_info* info,char* command,char ** parameters,char *&out);
#endif //MYSHELL_BUILDIN_COMMAND_H
